<?php
namespace robot;
/**
 * @Author: xuebingsi
 * @Date:   2019-01-12 14:43:55
 * @Last Modified by:   zhibinm
 * @Last Modified time: 2019-01-24 17:00:27
 */
/**
 * 
 */
class Robot 
{
	
	public static function send($content)
	{
		

		$url = "http://openapi.tuling123.com/openapi/api/v2";

		$arr = [
			'reqType'=>0,
			'perception'=>[
				'inputText'=>[
					'text'=>$content
				]
			],
			'userInfo'=>[
				'apiKey'=>'facc47b9f3afc7a493121bf6aacab53f',
				'userId'=>3
			]
		];

		$postData = json_encode($arr);


		$curl = curl_init();

		curl_setopt($curl, CURLOPT_URL, $url);

		curl_setopt($curl, CURLOPT_HEADER, false);

		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

		curl_setopt($curl, CURLOPT_POST, true);

		curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);


		$data = curl_exec($curl);


		$data = current(json_decode($data,true)['results']);

		return $data['values']['text'];

		// echo "<img src='http://file.tuling123.com/upload/image/xiaohua/20170726/1501079676428.jpg'>";

	}
}